<template>
	<view class="container">
		<view class="carousel">
			<swiper indicator-dots circular=true duration="400">
				<swiper-item class="swiper-item" v-for="(item,index) in imgList" :key="index">
					<view class="image-wrapper">
						<image
							:src="item" 
							class="loaded" 
							mode="aspectFill"
						></image>
					</view>
				</swiper-item>
			</swiper>
		</view>
		
		<view class="introduce-section">
			<view class="price-box">
				<text class="price-tip">¥</text>
				<text class="price">{{skuRetailPrice}}</text>
				<text class="m-price" style="display: none;">¥488</text>
				<text class="coupon-tip" style="display: none;">折</text>
			</view>
			<view>
				<text class="title">{{productName}}</text>
				<view class="v-share" @click="share">
					<text class="t-icon icon">&#xe625;</text>
					<text class="t-share">分享</text>
				</view>
			</view>
			
			<text class="t-pro-detail" v-if="productSellPoint!=''">{{productSellPoint}}</text>
			
			<view class="bot-row">
				<text>销量: {{saleNum}}</text>
				<text>库存: {{skuStock}}</text>
				<text>浏览量: {{viewNum}}</text>
			</view>
		</view>
		
		<view class="c-list">
			<view class="c-row b-b" @click="toSelectSku">
				<text class="tit">已选</text>
				<view class="con">
					<text class="selected-text" v-for="(sItem, sIndex) in specSelected" :key="sIndex">
						{{sItem.name}}
					</text>
					<text class="selected-text">
						{{buyNum}}件
					</text>
				</view>
				<text class="yticon icon-you"></text>
			</view>
			<view class="c-row b-b" v-if="couponList.length>0">
				<text class="tit">优惠券</text>
				<text class="con t-r red" @click="toggleMask('show')">领取优惠券</text>
				<text class="yticon icon-you"></text>
			</view>
			<view class="c-row b-b" style="display: none;">
				<text class="tit">促销活动</text>
				<view class="con-list">
					<text>新人首单送20元无门槛代金券</text>
					<text>订单满50减10</text>
					<text>订单满100减30</text>
					<text>单笔购买满两件免邮费</text>
				</view>
			</view>
			<view class="c-row b-b">
				<text class="tit">运费</text>
				<view class="bz-list con">
					<text>{{showExpressValue}}</text>
					<text style="display: none;">假一赔十 ·</text>
				</view>
			</view>
		</view>
		
		<!-- 评价 -->
		<view class="eva-section" style="display: none;">
			<view class="e-header">
				<text class="tit">评价</text>
				<text>(86)</text>
				<text class="tip">好评率 100%</text>
				<text class="yticon icon-you"></text>
			</view> 
			<view class="eva-box">
				<image class="portrait" src="http://img3.imgtn.bdimg.com/it/u=1150341365,1327279810&fm=26&gp=0.jpg" mode="aspectFill"></image>
				<view class="right">
					<text class="name">Leo yo</text>
					<text class="con">商品收到了，79元两件，质量不错，试了一下有点瘦，但是加个外罩很漂亮，我很喜欢</text>
					<view class="bot">
						<text class="attr">购买类型：XL 红色</text>
						<text class="time">2019-04-01 19:21</text>
					</view>
				</view>
			</view>
		</view>
		<view style="margin-top: 10px;margin-bottom: 20px;">
			<view v-for="(item,index) in diyData" :key="index">
				<zx-text v-if="item.name==='text'" :childData="item" :showState="showState" ref="zxText" ></zx-text>
		
			</view>
		</view>
		
		<view class="detail-desc" style="display: none;">
			<view class="d-header">
				<text></text>
			</view>
		</view>

		<!-- 规格-模态层弹窗 -->
		<view 
			class="popup spec" 
			:class="specClass"
			@touchmove.stop.prevent="stopPrevent"
			@click="toggleSpec"
		>
			<!-- 遮罩层 -->
			<view class="mask"></view>
			<view class="layer attr-content" @click.stop="stopPrevent">
				<view class="a-t">
					<image :src="imgList[0]"></image>
					<view class="right">
						<text class="price">¥{{skuRetailPrice}}</text>
						<text class="stock">库存：{{stock}}件</text>
						<view class="selected">
							已选：
							<text class="selected-text" v-for="(sItem, sIndex) in specSelected" :key="sIndex">
								{{sItem.name}}
							</text>
							<text class="selected-text">
								{{buyNum}}件
							</text>
						</view>
					</view>
				</view>
				<view v-for="(item,index) in specList" :key="index" class="attr-list">
					<text>{{item.name}}</text>
					<view class="item-list">
						<text 
							v-for="(childItem, childIndex) in specChildList" 
							v-if="childItem.pid === item.id"
							:key="childIndex" class="tit"
							:class="{selected: childItem.selected}"
							@click="selectSpec(childIndex, childItem.pid)"
						>
							{{childItem.name}}
						</text>
					</view>
				</view>
				<view class="buy-num">
					<text style="display: inline-block;">购买数量</text>
					<view style="display: inline-block;float: right;margin-top: -6px;"><uni-number-box :value="buyNum" :min="1" :max="stock" @change="changeBuyNum" /></view>
				</view>
				<button v-if="skuState==2" class="btn" style="width: 650rpx;background-color: rgb(255, 0, 0);" @click="toCart">确定</button>
				<button v-if="hasLogin==false&&skuState==3" open-type="getUserInfo"  @getuserinfo="mpGetUserInfo" @click="toLogin" type="primary" class="btn" style="width: 650rpx;background-color: rgb(255, 0, 0);">确定</button>
				<button v-if="hasLogin==true&&skuState==3" class="btn" style="width: 650rpx;background-color: rgb(255, 0, 0);" @click="toBuy">确定</button>
				<view v-if="skuState==1" style="text-align: center;">
					<button class="btn" style="display: inline-block;background-color:rgb(255, 162, 0)" @click="toCart">加入购物车</button>
					<button v-if="hasLogin==true" class="btn" style="display: inline-block;margin-left: 40rpx;background-color: rgb(255, 0, 0);" @click="toBuy">立即购买</button>					
					<button v-if="hasLogin==false" class="btn" open-type="getUserInfo"  @getuserinfo="mpGetUserInfo" @click="toLogin" style="display: inline-block;margin-left: 40rpx;background-color: rgb(255, 0, 0);">立即购买</button>					
				</view>

			</view>
		</view>

		<view class="goods-carts">
			<uni-goods-nav :options="options" :fill="true" :button-group="buttonGroup" @click="onClick" @buttonClick="buttonClick" ref="uniGoodsNav" />
		</view>
		<!-- 优惠券面板 -->
		<view class="mask" :class="maskState===0 ? 'none' : maskState===1 ? 'show' : ''" @click="toggleMask">
			<view class="mask-content" @click.stop.prevent="stopPrevent">
				<!-- 优惠券页面，仿mt -->
				<view class="coupon-item" v-for="(item,index) in couponList" :key="index" @click="getCoupon(item)">
					<view class="con">
						<view class="left">
							<text class="title">{{item.name}}</text>
							<text class="time">有效期{{item.startDate}}~{{item.endDate}}</text>
						</view>
						<view class="right">
							<text class="price" v-if="item.type=='代金券'">{{item.reduceMoney}}元</text>
							<text class="price" v-else>{{item.discountLimit}}折</text>
							<text>满{{item.useReuire}}元可用</text>
						</view>
						
						<view class="circle l"></view>
						<view class="circle r"></view>
					</view>
					<text class="tips">点击立即领取</text>
				</view>
			</view>
		</view>
		<!-- 底部分享弹窗 -->
		<uni-popup ref="showshare" :type="type" >
			<view class="uni-share">
				<view class="uni-share-content">
					<button open-type="share">发送给朋友</button>
					<button @click="toShowPoster(true)">分享到朋友圈</button>
				</view>
				<text class="uni-share-btn" @click="cancel('share')">取消分享</text>
			</view>
		</uni-popup>
		
		<zx-poster v-if="showPoster==true" :posterData="posterData" @cancel="canvasCancel"></zx-poster>
		
	</view>
</template>

<script>
	import zxText from '@/components/zx-diy/zx-text/zx-text.vue'
	import zxPoster from '@/components/zx-ui/zx-poster/zx-poster.vue'
	import myCloud from '@/common/js/cloud.js';
	import myConst from '@/common/js/const.js';
	import { formatTime,timestamp,genID } from '@/common/js/util.js';
	import uniNumberBox from '@/components/uni-ui/uni-number-box/uni-number-box.vue';
	import uniGoodsNav from '@/components/uni-ui/uni-goods-nav/uni-goods-nav.vue';
	import uniPopup from '@/components/uni-ui/uni-popup/uni-popup.vue'
	import uniIcons from '@/components/uni-ui/uni-icons/uni-icons.vue'
	import {
		mapState,
		mapMutations
	} from 'vuex';
	export default{
		components: {
			uniNumberBox,
			uniGoodsNav,
			uniPopup,
			uniIcons,
			zxText,
			zxPoster
		},
		data() {
			return {
				type: '',
				showState:1,  //判断是否显示编辑状态
				diyData:[],
				maskState: 0, //优惠券面板显示状态
				couponList: [],
				options: [

				{
					icon: 'shop',
					text: '店铺'
				}, {
					icon: 'headphones',
					text: '客服'
				}, {
					icon: 'cart',
					text: '购物车',
					info: 0 
				}],
				buttonGroup: [{
						text: '加入购物车',
						backgroundColor: '#ffa200 ',
						color: '#fff'
					},
					{
						text: '立即购买',
						backgroundColor: '#ff0000',
						color: '#fff'
					}
				],
				specClass: 'none',
				specSelected:[],
				id:'',
				mData:{},
				favorite: true,
				imgList: [],
				specList: [],
				specChildList: [],
				productName:'',
				productSellPoint:'',
				skuRetailPrice:'',
				skuArray:[],
				skuDetailArray:[],
				skuWeight:'',
				stock:0,
				skuStock:0,
				saleNum:0,
				viewNum:0,
				buyNum:1,
				skuState:0,
				skuAll:'',
				totalPrice:-1,
				express:'',
				expressFee:'',
				delivery:[],
				expressTemSelected:'',
				showExpressValue:'免运费',
				expressState:0,  //0 快递发送 1上门自取 2 快递发送+上门自取
				posterUrl:'',
				showPoster:false,
				posterData:{}
			};
		},
		computed:{
			...mapState(['hasLogin','userId','userInfo'])
		},
		async onLoad(options){
			
			//接收传值,id里面放的是标题，因为测试数据并没写id 
			if(options.id){
				this.id = options.id;
			}
			if (options.scene) {
				const scene = decodeURIComponent(options.scene)
				// const strs = scene.split('=');
				// this.id = strs[1];
				let newData = JSON.parse(scene);
				this.id = newData.id
			}
			console.log(this.id)
			this.initProData();
			this.initCouponData();
		},
		onShow() {
			this.initCartInfo(0);
		},
		onReady() {
		},
		onShareAppMessage(res) {
		    if (res.from === 'button') {// 来自页面内分享按钮
		      console.log(res.target)
		    }
		    return {
		      title: this.productName+" "+this.skuRetailPrice+"元",
		      path: '/pages/goods/goods-detail?id='+this.id
		    }
		 },
		methods:{
			initProData(){
				const req = {
					action: myConst.ACTION.QUERY,
					params: {
						id:this.id,
						type:3
					}
				}
				myCloud.callFunction(myConst.FUNC_NAME.B_GOODS,req,(data,e)=>{
					this.mData = data[0];
					console.log(data)
					this.diyData = data[0].proDetail;
					
					this.saleNum = data[0].saleNum;
					this.viewNum = data[0].viewNum;
					let proData = data[0].proData;
					
					// this.id = data[0]._id;
					this.productName = proData.productName;  //商品名称
					this.productSellPoint = proData.productSellPoint;  //商品卖点
					// this.unit = proData.unit;  //单位
					this.skuArray = proData.skuArray;  
					this.skuDetailArray = proData.skuDetailArray;
					this.skuRetailPrice = proData.skuRetailPrice;  //建议零售价格
					// this.skuCostPrice = proData.skuCostPrice;   //成本价
					this.skuStock = proData.skuStock;
					this.expressFee = proData.expressFee;  //统一运费
					this.express = proData.express;   //快递运费
					this.imgList = proData.imageList;
					this.delivery = proData.delivery;    //配送方式
					// this.showState = proData.showState;  //显示状态
					// this.groupList = proData.groupList;  //商品分组
					this.skuWeight = parseFloat(proData.skuWeight);  //商品重量
					// this.sales = proData.sales;
					this.expressTemSelected = proData.expressTemSelected;  //运费模板
					// for(let item in this.unitArray){
					// 	if(this.unitArray[item].id==this.unit.id){
					// 		this.unitIndex = item;
					// 		break;
					// 	}
					// }
					
					
					for(let item in this.skuArray){
						let tmp = {id:item,name:this.skuArray[item].name};
						this.specList.push(tmp);
						let sArray = this.skuArray[item].pro.split('#');
						
						for(var i=0;i<sArray.length;i++){
							let sItem = {id:i,pid:item,name:sArray[i]}
							this.specChildList.push(sItem)
						}
					}
					
					// 默认规格是价格最低的
					let sTmpSku = [];
					for(var i=0;i<this.skuDetailArray.length;i++){
						if(this.skuDetailArray[i].retailPrice==this.skuRetailPrice){    //找到价格最低的规格
							sTmpSku = this.skuDetailArray[i].name.split('-');
							this.stock = parseInt(this.skuDetailArray[i].stock);
							if(this.skuDetailArray[i].weight!='')
								this.skuWeight = parseFloat(this.skuDetailArray[i].weight)
							break;
						}
					}
					if(this.skuDetailArray.length==0){
						this.stock = parseInt(this.skuStock);
					}
				
					for(var i=0;i<this.specList.length;i++){
						for(let cItem of this.specChildList){
							if(cItem.pid === this.specList[i].id&&sTmpSku[i]==cItem.name){
								this.$set(cItem, 'selected', true);
								this.specSelected.push(cItem);
								break; //forEach不能使用break
							}
						}
					}		
				    
					//更新运费
					if(this.delivery.length>0){
						if(this.delivery[0]=='快递发货'){
							if(this.express=='统一邮费'){
								this.showExpressValue=(this.expressFee==0)?'免运费':(this.expressFee+'元')
							}else{
								this.showExpressValue='0~100元'
							}
							this.expressState=0;
						}
						if(this.delivery[0]=='到店自提'){
							this.expressState=1;
						}
						if(this.delivery.length==2){
							this.expressState=2;
						}
					}
					
					//存储预览次数
					const req = {
						action: myConst.ACTION.EDIT_BY_NUM,
						params: {
							id:this.id,
							viewNum:(parseInt(this.viewNum)+1),
							updatetime:new Date().getTime()
						}
					}
					myCloud.callFunction(myConst.FUNC_NAME.B_GOODS,req,(data,e)=>{
					
					},false,false)
				},true,false)
			},
			initCartInfo(n){
				let cartInfo = uni.getStorageSync('cart_info');
				if (cartInfo) {
				   let tmpArray = JSON.parse(cartInfo);	   
				   if(n==0){
					   this.options[2].info=tmpArray.length
				   }else if(n==1){
					   this.$refs.uniGoodsNav.setCartInfo(tmpArray.length);
				   }
				}
				
			},
			initCouponData(){
				this.couponList=[]
				const req = {
					action: myConst.ACTION.QUERY_BY_TIME,
					params:{}
				}
				myCloud.callFunction(myConst.FUNC_NAME.B_COUPON,req, (data, e) => {
					let that = this;
					if(this.hasLogin){
						for(var i=0;i<data.length;i++){
							if(data[i].hasGetTimes<data[i].sendNum)  //判断领取次数限制
							{
								const req = {
									action: myConst.ACTION.QUERY,
									params:{
										index:i,
										userId:this.userId,
										couponId:data[i]._id,
										updatetime:new Date().getTime()
									}
								}
								myCloud.callFunction(myConst.FUNC_NAME.B_COUPON_USER,req, (data2, e) => {
									if(parseInt(data[data2.index].limitNum)>parseInt(data2.count.total)){  //说明单用户还有未领取的优惠券
										this.couponList.push(data[data2.index])
									}
								},false,false)
							}
						}
					}else{
						for(var i=0;i<data.length;i++){
							if(parseInt(data[i].sendNum)>parseInt(data[i].hasGetTimes)){
								this.couponList.push(data[i])
							}
						}
					}
				},false,false)
			},
			togglePopup(type, open) {
				this.type = type
				this.$nextTick(() => {
					this.$refs['show' + open].open()
				})
			},
			cancel(type) {
				this.$refs['show' + type].close()
			},
			//规格弹窗开关
			toggleSpec() {
				if(this.specClass === 'show'){
					this.specClass = 'hide';
					setTimeout(() => {
						this.specClass = 'none';
					}, 250);
				}else if(this.specClass === 'none'){
					this.specClass = 'show';
				}
			},
			//选择规格
			selectSpec(index, pid){
				let list = this.specChildList;
				list.forEach(item=>{
					if(item.pid === pid){
						this.$set(item, 'selected', false);
					}
				})

				this.$set(list[index], 'selected', true);
				//存储已选择
				/**
				 * 修复选择规格存储错误
				 * 将这几行代码替换即可
				 * 选择的规格存放在specSelected中
				 */
				this.specSelected = []; 
				list.forEach(item=>{ 
					if(item.selected === true){ 
						this.specSelected.push(item); 
					} 
				})
				let sTmpSelected = '';
				for(var i=0;i<this.specSelected.length;i++){
					if(this.specSelected[i].selected){
						if(i==0){
							sTmpSelected = this.specSelected[i].name;
						}else{
							sTmpSelected = sTmpSelected + "-"+this.specSelected[i].name;
						}
						
					}
				}
				this.skuAll = sTmpSelected;
				//设置库存和剩余数量显示
				for(var i=0;i<this.skuDetailArray.length;i++){
					if(sTmpSelected==this.skuDetailArray[i].name){
						this.stock = parseInt(this.skuDetailArray[i].stock);
						this.skuRetailPrice =  this.skuDetailArray[i].retailPrice;
						if(this.skuDetailArray[i].weight!='')
							this.skuWeight = parseFloat(this.skuDetailArray[i].weight);
					}
				}
				
			},
			//分享
			share(){
				if(this.hasLogin){
					this.togglePopup('bottom', 'share')
				}else{
					this.$api.msg("请先登录系统")
					setTimeout(() => {
						this.$api.navTo('/pages/public/login')
					}, 350)
					
				}
				
			},
			//收藏
			toFavorite(){
				this.favorite = !this.favorite;
			},
			toCart(){
				this.toggleSpec();
				this.options[2].info++;
				let sTmpSelected = '';
				for(var i=0;i<this.specSelected.length;i++){
					if(this.specSelected[i].selected){
						if(i==0){
							sTmpSelected = this.specSelected[i].name;
						}else{
							sTmpSelected = sTmpSelected + "-"+this.specSelected[i].name;
						}
						
					}
				}
				this.skuAll = sTmpSelected;
				let tmp ={
					id:genID(),
					proId:this.id,
					number:parseInt(this.buyNum),
					weight:this.skuWeight,
					attr_val:this.skuAll,
					checked:true,
					image:this.imgList[0],
					loaded:'',
					price:this.skuRetailPrice,
					stock:this.skuStock,
					title:this.productName,
					delivery:this.delivery,
					express:this.express,
					expressFee:this.expressFee,
					expressTemSelected:this.expressTemSelected
				} 
							
				let cartInfo = uni.getStorageSync('cart_info');
				if (cartInfo) {
				   let tmpArray = JSON.parse(cartInfo);
				   let bHas = false;
				   for(var i=0;i<tmpArray.length;i++){
					   if(tmpArray[i].proId==this.id&&tmpArray[i].attr_val==this.skuAll){
						   bHas = true;
						   let tmp2 ={
								id:genID(),
								proId:this.id,
								number:parseInt(this.buyNum)+parseInt(tmpArray[i].number),
								weight:this.skuWeight,
								attr_val:this.skuAll,
								checked:true,
								image:this.imgList[0],
								loaded:'',
								price:this.skuRetailPrice,
								stock:this.skuStock,
								title:this.productName,
								delivery:this.delivery,
								express:this.express,
								expressFee:this.expressFee,
								expressTemSelected:this.expressTemSelected
						   }
						   tmpArray = tmpArray.splice(1,1);
						   tmpArray.push(tmp2)
						   break;
					   }
				   }
				   if(bHas==false){
					   tmpArray.push(tmp)
				   }
				   uni.setStorageSync('cart_info', JSON.stringify(tmpArray));
				}else{
					let tmpArray = [];
					tmpArray.push(tmp);
					uni.setStorageSync('cart_info', JSON.stringify(tmpArray));
				}
				this.initCartInfo(1)
			},
			toCartPage(){
				uni.reLaunch({
					url: `/pages/index/index?showPage=gwc`
				})
			},
			toBuy(){
				let sTmpSelected = '';
				for(var i=0;i<this.specSelected.length;i++){
					if(this.specSelected[i].selected){
						if(i==0){
							sTmpSelected = this.specSelected[i].name;
						}else{
							sTmpSelected = sTmpSelected + "-"+this.specSelected[i].name;
						}
						
					}
				}
				this.skuAll = sTmpSelected;
				let tmp ={
					id:genID(),
					proId:this.id,
					number:parseInt(this.buyNum),
					weight:this.skuWeight,
					attr_val:this.skuAll,
					checked:true,
					image:this.imgList[0],
					loaded:'',
					price:this.skuRetailPrice,
					stock:this.skuStock,
					title:this.productName,
					delivery:this.delivery,
					express:this.express,
					expressFee:this.expressFee,
					expressTemSelected:this.expressTemSelected
				} 
				let list = [];
				list.push(tmp)
				let goodsData = [];
				list.forEach(item=>{
					if(item.checked){
						goodsData.push(item)
					}
				})
				this.totalPrice = parseFloat(this.skuRetailPrice)*parseInt(this.buyNum)
				uni.redirectTo({
					url: `/pages/order/order-create?data=${JSON.stringify({
						goodsData: goodsData,
						totalPrice: this.totalPrice,
						expressState: this.expressState
					})}`
				})
			},
			buy(){
				this.skuState = 3;
				this.toggleSpec();
			},
			addCart(){
				this.skuState = 2;
				this.toggleSpec()
			},
			toSelectSku(){
				this.skuState = 1;
				this.toggleSpec();
			},
			stopPrevent(){},
			changeBuyNum(value) {
				this.buyNum = value;
				if(this.skuRetailPrice!=''){
					this.totalPrice = parseFloat(this.skuRetailPrice)*value
				}
				
			},
			onClick(e) {
				if(e.content.text=='购物车'){
					this.toCartPage()
				}
				if(e.content.text=='店铺'){
					this.toIndex()
				}
				if(e.content.text=='客服'){
					
				}
			},
			buttonClick(e) {
				if(e.index==0){
					this.addCart();
				}else if(e.index==1){
					this.buy()
				}
			},
			mpGetUserInfo(result) {
				// if (!this.hasLogin) {
				// 	if (result.detail.errMsg !== 'getUserInfo:ok') {
				// 		uni.showModal({
				// 			title: '获取用户信息失败',
				// 			content: '错误原因' + result.detail.errMsg,
				// 			showCancel: false
				// 		});
				// 		return;
				// 	}
				// 	myCloud.callFunction('s_user', {
				// 		action: 'wxlogin',
				// 		openid: this.openid,
				// 		userInfo: result.detail.userInfo,
				// 		updatetime: formatTime(),
				// 		timestamp: timestamp()
				// 	}, (data, e) => {
				// 		console.log(data)
				// 		this.setUserData(data);
				// 		this.$api.msg('登录成功');
				// 		this.toBuy()
				// 	}, true);
				// }
			},
			toLogin() {
				// #ifdef H5 
				if (!this.hasLogin) {
					uni.navigateTo({
						url: '/pages/public/login'
					})
				}
				// #endif
			},
			//显示优惠券面板
			toggleMask(type){
				let timer = type === 'show' ? 10 : 300;
				let	state = type === 'show' ? 1 : 0;
				this.maskState = 2;
				setTimeout(()=>{
					this.maskState = state;
				}, timer)
			},
			getCoupon(item){
				if(this.hasLogin){
					const req = {
						action: myConst.ACTION.ADD,
						params: {
							userId:this.userId,
							couponId:item._id,
							hasGetTimes:item.hasGetTimes,
							state:0,
							updatetime:new Date().getTime()
						}
					}
					myCloud.callFunction(myConst.FUNC_NAME.B_COUPON_USER,req, (data, e) => {
						console.log(data)
						this.initCouponData()
					},true,false)
				}else{
					this.$api.msg('请先登录系统再领取优惠券');
				}
				
			},
			toIndex(){
				uni.reLaunch({
				    url: '/pages/index/index'
				});
			},
			toShowPoster(e){
				let tmp={proId:this.id,productName:this.productName,price:this.skuRetailPrice,imgUrl:this.imgList[0],userData:this.userInfo}
				this.posterData = tmp;
				this.cancel('share')
				this.showPoster = e;
			},
			canvasCancel(){
				this.showPoster = false;
			}
		},

	}
</script>

<style lang='scss'>
	@import './../../common/css/mall.scss';
	page{
		background: $page-color-base;
		padding-bottom: 160upx;
	}
	.icon{
		font-size: 25px;
		font-family: iconfont;
		color: #666666;
	}
	.yticon {
		font-family: "yticon" !important;
		font-size: 16px;
		font-style: normal;
		-webkit-font-smoothing: antialiased;
		-moz-osx-font-smoothing: grayscale;
	}
	.container{
		background-color: #f8f8f8;
	}
	
	view,
	scroll-view,
	swiper,
	swiper-item,
	cover-view,
	cover-image,
	icon,
	text,
	rich-text,
	progress,
	button,
	checkbox,
	form,
	input,
	label,
	radio,
	slider,
	switch,
	textarea,
	navigator,
	audio,
	camera,
	image,
	video {
		box-sizing: border-box;
	}
	/* 骨架屏替代方案 */
	.Skeleton {
		background: #f3f3f3;
		padding: 20upx 0;
		border-radius: 8upx;
	}
	
	/* 图片载入替代方案 */
	.image-wrapper {
		font-size: 0;
		background: #f3f3f3;
		border-radius: 4px;
	
		image {
			width: 100%;
			height: 100%;
			transition: .6s;
			opacity: 0;
	
			&.loaded {
				opacity: 1;
			}
		}
	}
	
	.clamp {
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
		display: block;
	}
	
	.common-hover {
		background: #f5f5f5;
	}
	
	/*边框*/
	.b-b:after,
	.b-t:after {
		position: absolute;
		z-index: 3;
		left: 0;
		right: 0;
		height: 0;
		content: '';
		transform: scaleY(.5);
		border-bottom: 1px solid $border-color-base;
	}
	
	.b-b:after {
		bottom: 0;
	}
	
	.b-t:after {
		top: 0;
	}
	
	/* button样式改写 */
	uni-button,
	button {
		height: 80upx;
		line-height: 80upx;
		font-size: $font-lg + 2upx;
		font-weight: normal;
	
		&.no-border:before,
		&.no-border:after {
			border: 0;
		}
	}
	
	uni-button[type=default],
	button[type=default] {
		color: $font-color-dark;
	}
	
	/* input 样式 */
	.input-placeholder {
		color: #999999;
	}
	
	.placeholder {
		color: #999999;
	}
	.icon-you{
		font-size: $font-base + 2upx;
		color: #888;
	}
	.carousel {
		height: 722upx;
		position:relative;
		swiper{
			height: 100%;
		}
		.image-wrapper{
			width: 100%;
			height: 100%;
		}
		.swiper-item {
			display: flex;
			justify-content: center;
			align-content: center;
			height: 750upx;
			overflow: hidden;
			image {
				width: 100%;
				height: 100%;
			}
		}
		
	}
	
	/* 标题简介 */
	.introduce-section{
		background: #fff;
		padding: 20upx 30upx;
		
		.title{
			font-size: 32upx;
			color: $font-color-dark;
			height: 50upx;
			line-height: 50upx;
		}
		.v-share{
			position: relative;
			float: right;
			right: -16px;
			display: -webkit-box;
			display: -webkit-flex;
			display: flex;
			-webkit-box-orient: horizontal;
			-webkit-box-direction: normal;
			-webkit-flex-direction: row;
			flex-direction: row;
			-webkit-box-pack: justify;
			-webkit-justify-content: space-between;
			justify-content: space-between;
			-webkit-box-align: center;
			-webkit-align-items: center;
			align-items: center;
			background: #f8f8f8;
			padding: 3px 6px;
			border-top-left-radius: 1rem;
			border-bottom-left-radius: 1rem;
			height: 25px;
			.t-icon{
				color: rgb(153, 153, 153);
				font-size: 16px;
			}
			.t-share{
			    margin-left: 2px;
			    font-size: 12px;
			    color: #666;
			    line-height: normal;
			}
		}
		.price-box{
			display:flex;
			align-items:baseline;
			height: 64upx;
			padding: 10upx 0;
			font-size: 26upx;
			color:$uni-color-primary;
		}
		.price-tip{
			font-size: 16px;
			margin-right: 2px;
			font-weight: 500;
			line-height: 22px;
		}
		.price{
			font-size: 22px;
			font-weight: bolder;
			line-height: 24px;
		}
		.m-price{
			margin:0 12upx;
			color: $font-color-light;
			text-decoration: line-through;
		}
		.coupon-tip{
			align-items: center;
			padding: 4upx 10upx;
			background: $uni-color-primary;
			font-size: $font-sm;
			color: #fff;
			border-radius: 6upx;
			line-height: 1;
			transform: translateY(-4upx); 
		}
		.bot-row{
			display:flex;
			align-items:center;
			height: 50upx;
			font-size: $font-sm;
			color: $font-color-light;
			text{
				flex: 1;
			}
		}
	}
	
	.c-list{
		font-size: $font-sm + 2upx;
		color: $font-color-base;
		background: #fff;
		margin-top: 10px;
		.c-row{
			display:flex;
			align-items:center;
			padding: 20upx 30upx;
			position:relative;
		}
		.tit{
			width: 140upx;
		}
		.con{
			flex: 1;
			color: $font-color-dark;
			.selected-text{
				margin-right: 10upx;
			}
		}
		.bz-list{
			height: 40upx;
			font-size: $font-sm+2upx;
			color: $font-color-dark;
			text{
				display: inline-block;
				margin-right: 30upx;
			}
		}
		.con-list{
			flex: 1;
			display:flex;
			flex-direction: column;
			color: $font-color-dark;
			line-height: 40upx;
		}
		.red{
			color: $uni-color-primary;
		}
	}
	
	/* 评价 */
	.eva-section{
		display: flex;
		flex-direction: column;
		padding: 20upx 30upx;
		background: #fff;
		margin-top: 16upx;
		.e-header{
			display: flex;
			align-items: center;
			height: 70upx;
			font-size: $font-sm + 2upx;
			color: $font-color-light;
			.tit{
				font-size: $font-base + 2upx;
				color: $font-color-dark;
				margin-right: 4upx;
			}
			.tip{
				flex: 1;
				text-align: right;
			}
			.icon-you{
				margin-left: 10upx;
			}
		}
	}
	.eva-box{
		display: flex;
		padding: 20upx 0;
		.portrait{
			flex-shrink: 0;
			width: 80upx;
			height: 80upx;
			border-radius: 100px;
		}
		.right{
			flex: 1;
			display: flex;
			flex-direction: column;
			font-size: $font-base;
			color: $font-color-base;
			padding-left: 26upx;
			.con{
				font-size: $font-base;
				color: $font-color-dark;
				padding: 20upx 0;
			}
			.bot{
				display: flex;
				justify-content: space-between;
				font-size: $font-sm;
				color:$font-color-light;
			}
		}
	}
	/*  详情 */
	.detail-desc{
		background: #fff;
		margin-top: 16upx;
		.d-header{
			display: flex;
			justify-content: center;
			align-items: center;
			height: 80upx;
			font-size: $font-base + 2upx;
			color: $font-color-dark;
			position: relative;
				
			text{
				padding: 0 20upx;
				background: #fff;
				position: relative;
				z-index: 1;
			}
			&:after{
				position: absolute;
				left: 50%;
				top: 50%;
				transform: translateX(-50%);
				width: 300upx;
				height: 0;
				content: '';
				border-bottom: 1px solid #ccc; 
			}
		}
	}
	
	/* 规格选择弹窗 */
	.attr-content{
		padding: 10upx 30upx;
		.a-t{
			display: flex;
			image{
				width: 170upx;
				height: 170upx;
				flex-shrink: 0;
				margin-top: -40upx;
				border-radius: 8upx;;
			}
			.right{
				display: flex;
				flex-direction: column;
				padding-left: 24upx;
				font-size: $font-sm + 2upx;
				color: $font-color-base;
				line-height: 42upx;
				.price{
					font-size: $font-lg;
					color: $uni-color-primary;
					margin-bottom: 10upx;
				}
				.selected-text{
					margin-right: 10upx;
				}
			}
		}
		.attr-list{
			display: flex;
			flex-direction: column;
			font-size: $font-base + 2upx;
			color: $font-color-base;
			padding-top: 30upx;
			padding-left: 10upx;
		}
		.buy-num{
			height: 50px;
			font-size: $font-base + 2upx;
			color: $font-color-base;
			padding-top: 30upx;
			padding-left: 10upx;
		}
		.item-list{
			padding: 20upx 0 0;
			display: flex;
			flex-wrap: wrap;
			text{
				display: flex;
				align-items: center;
				justify-content: center;
				background: #eee;
				margin-right: 20upx;
				margin-bottom: 20upx;
				border-radius: 100upx;
				min-width: 60upx;
				height: 60upx;
				padding: 0 20upx;
				font-size: $font-base;
				color: $font-color-dark;
			}
			.selected{
				background: #fbebee;
				color: $uni-color-primary;
			}
		}
	}
	
	/*  弹出层 */
	.popup {
		position: fixed;
		left: 0;
		top: 0;
		right: 0;
		bottom: 0;
		z-index: 99;
		
		&.show {
			display: block;
			.mask{
				animation: showPopup 0.2s linear both;
			}
			.layer {
				animation: showLayer 0.2s linear both;
			}
		}
		&.hide {
			.mask{
				animation: hidePopup 0.2s linear both;
			}
			.layer {
				animation: hideLayer 0.2s linear both;
			}
		}
		&.none {
			display: none;
		}
		.mask{
			position: fixed;
			top: 0;
			width: 100%;
			height: 100%;
			z-index: 1;
			background-color: rgba(0, 0, 0, 0.4);
		}
		.layer {
			position: fixed;
			z-index: 99;
			bottom: 0;
			width: 100%;
			/* min-height: 40vh; */
			border-radius: 10upx 10upx 0 0;
			background-color: #fff;
			.btn{
				height: 66upx;
				line-height: 66upx;
				width: 320rpx;
				border-radius: 100upx;
				background: $uni-color-primary;
				font-size: $font-base + 2upx;
				color: #fff;
				margin: 30upx auto 20upx;
			}
		}
		@keyframes showPopup {
			0% {
				opacity: 0;
			}
			100% {
				opacity: 1;
			}
		}
		@keyframes hidePopup {
			0% {
				opacity: 1;
			}
			100% {
				opacity: 0;
			}
		}
		@keyframes showLayer {
			0% {
				transform: translateY(120%);
			}
			100% {
				transform: translateY(0%);
			}
		}
		@keyframes hideLayer {
			0% {
				transform: translateY(0);
			}
			100% {
				transform: translateY(120%);
			}
		}
	}
	
	/* 底部操作菜单 */
	.page-bottom{
		position:fixed;
		left: 30upx;
		bottom:30upx;
		z-index: 95;
		display: flex;
		justify-content: center;
		align-items: center;
		width: 690upx;
		height: 100upx;
		background: rgba(255,255,255,.9);
		box-shadow: 0 0 20upx 0 rgba(0,0,0,.5);
		border-radius: 16upx;
		
		.p-b-btn{
			display:flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			font-size: $font-sm;
			color: $font-color-base;
			width: 96upx;
			height: 80upx;
			.yticon{
				font-size: 40upx;
				line-height: 48upx;
				color: $font-color-light;
			}
			&.active, &.active .yticon{
				color: $uni-color-primary;
			}
			.icon-fenxiang2{
				font-size: 42upx;
				transform: translateY(-2upx);
			}
			.icon-shoucang{
				font-size: 46upx;
			}
		}
		.action-btn-group{
			display: flex;
			height: 76upx;
			border-radius: 100px;
			overflow: hidden;
			box-shadow: 0 20upx 40upx -16upx #FF6146;
			box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
			background: linear-gradient(to right, #ffac30,#FF6146,#F56C6C);
			margin-left: 20upx;
			position:relative;
			&:after{
				content: '';
				position:absolute;
				top: 50%;
				right: 50%;
				transform: translateY(-50%);
				height: 28upx;
				width: 0;
				border-right: 1px solid rgba(255,255,255,.5);
			}
			.action-btn{
				display:flex;
				align-items: center;
				justify-content: center;
				width: 180upx;
				height: 100%;
				font-size: $font-base ;
				padding: 0;
				border-radius: 0;
				background: transparent;
			}
		}
	}
	
	.t-pro-detail{
		font-size: 12px;
		line-height: 16px;
		color: #999;
		height: 16px;
		display: block;
	}
	.goods-carts {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		z-index: 10;
	}
	/* 优惠券面板 */
	.mask{
		display: flex;
		align-items: flex-end;
		position: fixed;
		left: 0;
		top: var(--window-top);
		bottom: 0;
		width: 100%;
		background: rgba(0,0,0,0);
		z-index: 9995;
		transition: .3s;
		
		.mask-content{
			width: 100%;
			min-height: 30vh;
			max-height: 70vh;
			background: #f3f3f3;
			transform: translateY(100%);
			transition: .3s;
			overflow-y:scroll;
		}
		&.none{
			display: none;
		}
		&.show{
			background: rgba(0,0,0,.4);
			
			.mask-content{
				transform: translateY(0);
			}
		}
	}
	/* 优惠券列表 */
	.coupon-item{
		display: flex;
		flex-direction: column;
		margin: 20upx 24upx;
		background: #fff;
		.con{
			display: flex;
			align-items: center;
			position: relative;
			height: 120upx;
			padding: 0 30upx;
			&:after{
				position: absolute;
				left: 0;
				bottom: 0;
				content: '';
				width: 100%;
				height: 0;
				border-bottom: 1px dashed #f3f3f3;
				transform: scaleY(50%);
			}
		}
		.left{
			display: flex;
			flex-direction: column;
			justify-content: center;
			flex: 1;
			overflow: hidden;
			height: 100upx;
		}
		.title{
			font-size: 32upx;
			color: $font-color-dark;
			margin-bottom: 10upx;
		}
		.time{
			font-size: 24upx;
			color: $font-color-light;
		}
		.right{
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			font-size: 26upx;
			color: $font-color-base;
			height: 100upx;
		}
		.price{
			font-size: 44upx;
			color: $base-color;
			&:before{
				content: '￥';
				font-size: 34upx;
			}
		}
		.tips{
			font-size: 24upx;
			color: $font-color-light;
			line-height: 60upx;
			padding-left: 30upx;
		}
		.circle{
			position: absolute;
			left: -6upx;
			bottom: -10upx;
			z-index: 10;
			width: 20upx;
			height: 20upx;
			background: #f3f3f3;
			border-radius: 100px;
			&.r{
				left: auto;
				right: -6upx;
			}
		}
	}
	/* 底部分享 */
	.uni-share {
		/* #ifndef APP-NVUE */
		display: flex;
		flex-direction: column;
		/* #endif */
		background-color: #fff;
	}
	
	.uni-share-content {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		flex-wrap: wrap;
		justify-content: center;
		padding: 15px;
	}
	
	.uni-share-btn {
		height: 90rpx;
		line-height: 90rpx;
		font-size: 14px;
		border-top-color: #f5f5f5;
		border-top-width: 1px;
		border-top-style: solid;
		text-align: center;
		color: #666;
	}
	/* 插屏广告 */
	.uni-image {
		position: relative;
	}
	
	.image {
		width: 200px;
		height: 200px;
	}
	
	.uni-image-close {
		margin-top: 20px;
		text-align: center;
	}
	.canvas{
	    position: fixed !important;
	    top: 0 !important;
	    left: 0 !important;
	    display: block !important;
	    width: 100% !important;
	    height: 100% !important;
	    z-index: 10;
	}
</style>